package com.medical.service.impl;

import com.medical.mapper.ItemizeUsageMapper;
import com.medical.pojo.ItemizeUsage;
import com.medical.pojo.ItemizeUsageVO;
import com.medical.service.ItemizeUsageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class ItemizeUsageServiceImpl implements ItemizeUsageService {

    @Autowired
    private ItemizeUsageMapper itemizeUsageMapper;


    /**
     * 查询所有细目使用情况
     *
     * @param itemizeUsageVO 细目使用情况的视图对象，包含查询条件
     * @return 返回所有细目使用情况的列表
     */
    @Override
    public List<ItemizeUsage> findAll(ItemizeUsageVO itemizeUsageVO) {
        return itemizeUsageMapper.findAll(itemizeUsageVO);
    }

    /**
     * 查询照明耗能
     * itemizeUsageVO 细目使用情况的视图对象，包含查询条件
     * @return 返回所有照明耗能的列表
     */
    @Override
    public List<String> findLightingUsage(ItemizeUsageVO itemizeUsageVO) {
        List<ItemizeUsage> list = itemizeUsageMapper.findAll(itemizeUsageVO);
        List<String> lightingUsage = list.stream().map(ItemizeUsage::getLightingUsage).collect(Collectors.toList());
        return lightingUsage;
    }

    /**
     * 查询空调耗能
     *  itemizeUsageVO 细目使用情况的视图对象，包含查询条件
     * @return 返回所有空调耗能的列表
     */
    @Override
    public List<String> findConditioningUsage(ItemizeUsageVO itemizeUsageVO) {
        List<ItemizeUsage> list = itemizeUsageMapper.findAll(itemizeUsageVO);
        List<String> conditioningUsage = list.stream().map(ItemizeUsage::getConditioningUsage).collect(Collectors.toList());
        return conditioningUsage;
    }

    /**
     * 查询动力耗能
     * itemizeUsageVO 细目使用情况的视图对象，包含查询条件
     * @return 返回所有动力耗能的列表
     */
    @Override
    public List<String> findPowerUsage(ItemizeUsageVO itemizeUsageVO) {
        List<ItemizeUsage> list = itemizeUsageMapper.findAll(itemizeUsageVO);
        List<String> powerUsage = list.stream().map(ItemizeUsage::getPowerUsage).collect(Collectors.toList());
        return powerUsage;
    }

    /**
     * 查询特殊耗能
     *  itemizeUsageVO 细目使用情况的视图对象，包含查询条件
     * @return 返回所有特殊耗能的列表
     */
    @Override
    public List<String> findSpecialUsage(ItemizeUsageVO itemizeUsageVO) {
        List<ItemizeUsage> list = itemizeUsageMapper.findAll(itemizeUsageVO);
        List<String> specialUsage = list.stream().map(ItemizeUsage::getSpecialUsage).collect(Collectors.toList());
        return specialUsage;
    }
}
